<?php
# 变量调试器
class debug{
	function __construct($args,$trace){
		$this->debug($args,$trace);
	}
	
	function debug($args,$trace) {
		echo '---------------------debug info.---------------------<pre>';
		foreach ($args as $value) {
			if(is_null($value)){
				echo '[is_null]';
			}elseif(is_bool($value) || empty($value)){
				var_dump($value);
			}else{
				print_r($value);
			}
			echo '<br>';
		}
		$next = array_merge(
						array(
							'line'		=> '??',
							'file'		=> '[internal]',
							'class'		=> null,
							'function'	=> '[main]'
						),
						$trace[0]
					);
		
		if(strpos($next['file'],DOCUMENT_LIBRARIES)===0){
			$next['file'] = str_replace(DOCUMENT_LIBRARIES, DS.'libraries'.DS,$next['file']);
		}elseif(strpos($next['file'],DOCUMENT_MODEL)===0){
			$next['file'] = str_replace(DOCUMENT_LIBRARIES, DS.'MODEL'.DS,$next['file']);
		}elseif(strpos($next['file'],DOCUMENT_ROOT)===0){
			$next['file'] = str_replace(DOCUMENT_ROOT, '',$next['file']);
		}
		echo '---------------------debug ended---------------------';
		echo '<div style="color:red;">'.$next['file'].' line:'.$next['line'].'</div>';
		if(in_array('debug',$args)){
			print_r($trace);
		}
		copyright();
		echo '</pre>';
		exit();
	}
}

?>